import 'package:get/get.dart';

class UserInfoModel {
  int? id;
  String? fName;
  String? birthDate;
  String? image;
  String? phone;
  int? orderCount;
  int? memberSinceDays;
  String? refCode;
  double? walletBalance;
  double? referralPoint;
  double? loyalityPoint;
  int? driverLanguagePreference;
  String? appLanguage;
  String? alternativePhone;
  bool? activeOrderExist;
  int? lastActiveOrderId;
  String? referredBy;
  bool? isReferralCodeEditable;
  int? unpaidOrderCount;

  UserInfoModel(
      {this.id,
      this.fName,
      this.birthDate,
      this.image,
      this.phone,
      this.orderCount,
      this.memberSinceDays,
      this.refCode,
      this.walletBalance,
      this.referralPoint,
      this.loyalityPoint,
      this.driverLanguagePreference,
      this.appLanguage,
      this.alternativePhone,
      this.lastActiveOrderId,
      this.referredBy,
      this.isReferralCodeEditable,
      this.unpaidOrderCount});

  UserInfoModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    fName = json['f_name'] != null ? json['f_name'] : "Not Set".tr;
    birthDate = json['date_of_birth'] ?? "";
    image = json['image'];
    phone = json['phone'];
    orderCount = json['order_count'];
    memberSinceDays = json['member_since_days'];
    refCode = json['ref_code'];
    walletBalance = double.tryParse(json['wallet_balance'] ?? '0.00');
    referralPoint = double.tryParse(json['referal_point'] ?? '0.00');
    loyalityPoint = double.tryParse(json['loyalty_point'] ?? '0.00');
    driverLanguagePreference = json['english_speaker'];
    appLanguage = json['app_language'];
    alternativePhone = json['alternative_phone'];
    activeOrderExist = json['repeat_order_tip'];
    lastActiveOrderId = json['last_active_order_id'];
    referredBy = json['refered_by'];
    isReferralCodeEditable = json['referred_code_editable'];
    unpaidOrderCount = json['unpaid_incomplete_order_count'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['f_name'] = this.fName;
    data['date_of_birth'] = this.birthDate;
    data['image'] = this.image;
    data['phone'] = this.phone;
    data['order_count'] = this.orderCount;
    data['member_since_days'] = this.memberSinceDays;
    data['ref_code'] = this.refCode;
    data['wallet_balance'] = this.walletBalance;
    data['referal_point'] = this.referralPoint;
    data['loyalty_point'] = this.loyalityPoint;
    data['english_speaker'] = this.driverLanguagePreference;
    data['app_language'] = this.appLanguage;
    data['alternative_phone'] = this.alternativePhone;
    data['last_active_order_id'] = this.lastActiveOrderId;
    data['refered_by'] = this.referredBy;
    data['referred_code_editable'] = this.isReferralCodeEditable;
    return data;
  }
}
